package indi.chengx.walty.ui.lisener;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JButton;

import org.freedesktop.gstreamer.Pipeline;

import indi.chengx.walty.dirve.Camera;
import indi.chengx.walty.util.Console;

public class StartVideoListener implements MouseListener {
	private final String TAG = this.getClass().getSimpleName();
	private Camera camera;
	private JButton btn;
	private boolean isPlaying = false;
	public StartVideoListener(Camera camera,JButton btn) {
		this.camera = camera;
		this.btn = btn;
	}
	
	public void mouseClicked(MouseEvent e) {
		// TODO Auto-generated method stub
		Console.log(TAG, "mouseClicked");
		if(isPlaying) {
			camera.pauseVideo();
			btn.setText("play");
			isPlaying = false;
			Console.log(TAG, "if in");
		}else {
			camera.playVideo();
			btn.setText("pause");
			isPlaying = true;
			Console.log(TAG, "if else");
		}
		//isPlaying = !isPlaying;
		Console.log(TAG, "mouseClicked is over");
	}

	public void mousePressed(MouseEvent e) {
		// TODO Auto-generated method stub

	}

	public void mouseReleased(MouseEvent e) {
		// TODO Auto-generated method stub

	}

	public void mouseEntered(MouseEvent e) {
		// TODO Auto-generated method stub

	}

	public void mouseExited(MouseEvent e) {
		// TODO Auto-generated method stub

	}

}
